package com.culture.bootdemo.算法.leetcode;

/**
 * @Author: wen
 * @DateTime: 2025-04-16 10:06
 * @Description: 时间复杂度：O(n)
 * 空间复杂度：O(1)（原地操作，不用新数组）
 **/
public class 去重排序数组 {

    public int removeDuplicates(int[] nums) {
        int n = nums.length;
        if (n == 0) {
            return 0;
        }
        int fast = 1;
        int slow = 1;
        while (fast < n) {
            if (nums[fast] != nums[fast - 1]) {
                nums[slow] = nums[fast];
                slow++;
            }
            fast++;
        }
        return slow;
    }


}
